<?php
/**
 * @Author: Awe
 * @Date:   2018-10-20 22:30:23
 * @Last Modified by:   Awe
 * @Last Modified time: 2019-03-26 14:57:33
 */
class Order_OrderController extends BaseAuthController {
    public function init(){
        parent::init();
    }
    public function indexAction(){
        if ($this->getRequest()->isXmlHttpRequest() OR $this->getRequest()->get("inajax") == 1) {
            //如果是ajax提交
            $this->getAjaxUserList();
            exit;
        }
        $Business = Common::ImportBusiness("Order" ,"Order" );
        $tData = $Business->orderTotal($this->userInfo['cid']);
        $res = array(
            'pageSize'=> 10 ,
            'tData' => $tData,
            't_count' => isset($tData['t_count'])?$tData['t_count']/100:0,
            'y_count' => isset($tData['y_count'])?$tData['y_count']/100:0,
        );
        $this->displayTemplate('order/order_index' , $res);
    }
    private function getAjaxUserList(){
        $params = $this->getParams();
        $pageSize =  isset($params['limit']) ? intval($params['limit']):10;
        $Business = Common::ImportBusiness("Order" ,"Order" );
        $params['cid'] = $this->userInfo['cid'];
        $data = $Business->getOrderList($params,$pageSize);
        $list = $data['list'];
        if( !empty($list) ){
            foreach ($list as $key => $value) {
                $role_str = '';
                $list[$key]['money'] ="￥". $value['money']/100 ;
            }
        }
        $this->echoListJson(0,"OK" ,$data['total'] ,$list );
    }
   
}